package ma.zhiqiang.dataline.core.dto;

import lombok.Getter;
import lombok.NoArgsConstructor;
import ma.zhiqiang.dataline.util.HandlerUtil;

@Getter
@NoArgsConstructor
public class SourceRecord {

    String str;

    public SourceRecord(String str) {
        this.str = str;
    }
    public SourceRecord(String str,String fieldHandlerClass){
       if(null!=fieldHandlerClass){
           str = HandlerUtil.stringFieldHandle(fieldHandlerClass,str);
       }
       this.str = str;
    }
    ColumnMap<String, Column> columnMap;

    public SourceRecord(Integer capacity) {
        this.columnMap = new ColumnMap<String,Column>(capacity);
    }
    public void addColumn(Column column){
        addColumn(column,null);
    }
    public void addColumn(Column column,String fieldHandlerClass){
        if(null!=fieldHandlerClass){
            column = HandlerUtil.columnFieldHandle(fieldHandlerClass, column);
        }
        columnMap.put(column.getAlias(),column);
    }
    public Column getColumn(String alias){
        return columnMap.get(alias);
    }

}
